home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5573 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  61 lines

  1. Path: news.mistral.co.uk!usenet
  2. From: mikebarnard@mistral.co.uk (Mike Barnard)
  3. Newsgroups: comp.lang.c
  4. Subject: Initialising structure members - help please!
  5. Date: Mon, 19 Feb 1996 23:26:51 GMT
  6. Organization: Mistral Internet (Brighton)
  7. Message-ID: <4gb8hn$3m8@news.mistral.co.uk>
  8. NNTP-Posting-Host: l105.mistral.co.uk
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi all.
  12.  
  13. I'm a learner. I am trying to create a function to display a list of
  14. menu items using a doubly linked list. My problem is in initialising
  15. the members of the individual menu items.
  16.  
  17. Within a function called VPCMENU.C I have created a structure...
  18.  
  19. // Define a structure to hold the menu item information.
  20.  
  21. struct    menuitem
  22.     {
  23.     int number;            // Item 1, item 2 etc.
  24.     char description[70];        // Room for a text description
  25.     struct menuitem *next;        // Pointer to next menu item
  26.     struct menuitem *last;        // Pointer to last menu item
  27.     };
  28.  
  29. Now I create 5 instances of variables of the type menuitem...
  30.  
  31. // Define the instances of the structure.
  32.  
  33. struct menuitem one,two,three,four,five;
  34.  
  35. Now, the fun (not) bit. I tried to initialise the items with...
  36.  
  37. one.number = 1;
  38. one.description = "1.   Calculate a minefield";
  39. one.next = two;
  40. one.last = five;
  41.  
  42. The first one passes OK, but the second one creates an error. As it
  43. stands it says "Lvalue required". Help says "The left side of an
  44. assignment operator must be an addressable expression." I don't know
  45. about the third and fourth ones. Yet.
  46.  
  47. This is an almost exact copy of the structure examples in my book.
  48. (The beginners guide to C by Wrox). Page 387 for those who have it.
  49.  
  50. So, can anyone help please? (I must get snippets!). This is for a PC
  51. in text mode using Borland C++ 3.0. The completed program is to do
  52. calculations for the e-mail game VGA Planets.
  53.  
  54. Thanks.
  55.  
  56.  
  57. Mic.
  58. From windy Worthing; England.
  59. mikebarnard@mistral.co.uk
  60.  
  61.